﻿<Window x:Class="PlaylistCopy.Views.SummaryWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:p="clr-namespace:PlaylistCopy.Properties"
        xmlns:impl="clr-namespace:PlaylistCopy.ViewModels.Impl"
        xmlns:converters="clr-namespace:PlaylistCopy.Converters"
        xmlns:logging="clr-namespace:PlaylistCopy.Logging"
        xmlns:impl1="clr-namespace:PlaylistCopy.Services.Impl"
        Title="SummaryWindow" Height="400" Width="600"
        DataContext="{Binding Source={StaticResource ViewModelLocator}, Path=SummaryWindowVm}"
        WindowStartupLocation="CenterScreen"
        ResizeMode="NoResize"
        WindowStyle="SingleBorderWindow"
        impl1:WindowFactory.IsRegisteredView="True" 
        >
    <Window.Resources>
        <converters:EnumToVisibilityConverter x:Key="EnumToVisibilityConverter" />
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
        </Grid.RowDefinitions>
        
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition Width="*"></ColumnDefinition>
            </Grid.ColumnDefinitions>

            <Image VerticalAlignment="Center" Margin="5" HorizontalAlignment="Center" Width="32" Height="32" Source="/PlaylistCopy;component/Images/32/accept_button.png" 
                   Visibility="{Binding Status,
                            Converter={StaticResource EnumToVisibilityConverter},
                            ConverterParameter={x:Static impl:SummaryStatus.Success}}"></Image>
            <Image Grid.Column="0" VerticalAlignment="Center" Margin="5" HorizontalAlignment="Center" Width="32" Height="32" Source="/PlaylistCopy;component/Images/32/cross_shield.png"
                                      Visibility="{Binding Status,
                            Converter={StaticResource EnumToVisibilityConverter},
                            ConverterParameter={x:Static impl:SummaryStatus.Error}}"></Image>

            <TextBlock Grid.Column="1" VerticalAlignment="Center" Margin="5" FontWeight="Bold"
                       Visibility="{Binding Status,
                            Converter={StaticResource EnumToVisibilityConverter},
                            ConverterParameter={x:Static impl:SummaryStatus.Success}}" Text="{x:Static p:Resources.SuccessfullyCompleted}"></TextBlock>

            <TextBlock Grid.Column="1" 
                       Visibility="{Binding Status,
                            Converter={StaticResource EnumToVisibilityConverter},
                            ConverterParameter={x:Static impl:SummaryStatus.Error}}" Text="{x:Static p:Resources.ErrorOccured}"></TextBlock>
        </Grid>
        
        <ListView  Grid.Row="1" ItemsSource="{Binding Logs}" Margin="5">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="*"></ColumnDefinition>
                        </Grid.ColumnDefinitions>

                        <Image VerticalAlignment="Center" Margin="5" HorizontalAlignment="Center" Width="16" Height="16" Source="/PlaylistCopy;component/Images/information.png" 
                            Visibility="{Binding Type,
                                            Converter={StaticResource EnumToVisibilityConverter},
                                            ConverterParameter={x:Static logging:BufferedLogType.Info}}"></Image>

                        <Image Grid.Column="0" VerticalAlignment="Center" Margin="5" HorizontalAlignment="Center" Width="16" Height="16" Source="/PlaylistCopy;component/Images/cross_shield.png" 
                            Visibility="{Binding Type,
                                            Converter={StaticResource EnumToVisibilityConverter},
                                            ConverterParameter={x:Static logging:BufferedLogType.Error}}"></Image>

                        <Image Grid.Column="0" VerticalAlignment="Center" Margin="5" HorizontalAlignment="Center" Width="16" Height="16" Source="/PlaylistCopy;component/Images/warning.png" 
                            Visibility="{Binding Type,
                                            Converter={StaticResource EnumToVisibilityConverter},
                                            ConverterParameter={x:Static logging:BufferedLogType.Warning}}"></Image>
                        
                        <TextBlock Grid.Column="1" Text="{Binding Message}" VerticalAlignment="Center" TextWrapping="Wrap"></TextBlock>
                    </Grid>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

        <StackPanel Grid.Row="2" Orientation="Horizontal" FlowDirection="RightToLeft">
            <Button Margin="5" Padding="5" Width="80" Command="{Binding Close}">
                <StackPanel Orientation="Horizontal" FlowDirection="LeftToRight">
                    <Image Width="16" Height="16"  Source="/PlaylistCopy;component/Images/cross.png" Margin="0,0,5,0" />
                    <TextBlock Text="{x:Static p:Resources.Close}" VerticalAlignment="Center" />
                </StackPanel>
            </Button>
            <Button Margin="5" Padding="5" Width="100" Command="{Binding SaveAs}">
                <StackPanel Orientation="Horizontal" FlowDirection="LeftToRight">
                    <Image Width="16" Height="16"  Source="/PlaylistCopy;component/Images/save_as.png" Margin="0,0,5,0" />
                    <TextBlock Text="{x:Static p:Resources.SaveAs}" VerticalAlignment="Center" />
                </StackPanel>
            </Button>
        </StackPanel>
    </Grid>
</Window>
